import 'dart:math';

import 'package:any_reader/config/resource_manager.dart';
import 'package:any_reader/public.dart';

class Item extends StatelessWidget {
  final BookInfoModel model;
  Item({Key key, this.model}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsets.fromLTRB(
          ScreenUtil().setWidth(30), 0, ScreenUtil().setWidth(30), 0),
      child: InkWell(
        child: new SizedBox(
          height: ScreenUtil().setHeight(200),
          child: Row(
            children: <Widget>[
              new Expanded(
                flex: 1,
                child: Padding(
                  padding: EdgeInsets.all(0),
                  child: Stack(
                    children: <Widget>[
                      Container(
                        height: ScreenUtil().setHeight(200),
                        width: ScreenUtil().setWidth(200),
                        child: CachedImage(
                          url: model.bookInfo.book.imgUrl,
                          fit: BoxFit.fill,
                        ),
                      ),
                      Positioned(
                        left: 0,
                        top: 0,
                        height: ScreenUtil().setHeight(200),
                        width: ScreenUtil().setWidth(200),
                        child: Container(
                          color: Color.fromARGB(60, 0, 0, 0),
                        ),
                      )
                    ],
                  ),
                ),
              ),
              new Expanded(
                flex: 3,
                child: Padding(
                  padding: EdgeInsets.fromLTRB(
                    ScreenUtil().setHeight(10),
                    ScreenUtil().setHeight(7),
                    ScreenUtil().setHeight(10),
                    ScreenUtil().setHeight(20),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Container(
                        child: Text(
                          model.bookInfo.book.title ?? "",
                          style: TextStyle(
                            fontSize: ScreenUtil()
                                .setSp(36, allowFontScalingSelf: true),
                            color:
                                model.themeModel.customThemeData.mainTextColor,
                          ),
                        ),
                      ),
                      Container(
                        child: Text(
                          model.bookInfo.book.author ?? "",
                          style: TextStyle(
                            fontSize: 14,
                            color: Color(0xFFf88a3f),
                          ),
                        ),
                      ),
                      Expanded(
                        flex: 3,
                        child: Container(
                          child: Text(
                            model.bookInfo.book.description ?? "暂无简介",
                            maxLines: 2,
                            softWrap: true,
                            overflow: TextOverflow.ellipsis,
                            textAlign: TextAlign.left,
                            style: new TextStyle(
                                fontSize: 12, color: Color(0xFF686868)),
                          ),
                          width: ScreenUtil().setWidth(700),
                          alignment: Alignment.topLeft,
                          margin: EdgeInsets.only(
                            bottom: ScreenUtil().setHeight(0),
                          ),
                          padding: EdgeInsets.only(
                            bottom: ScreenUtil().setHeight(20),
                          ),
                        ),
                      ),
                      Expanded(
                        flex: 1,
                        child: Container(
                          alignment: Alignment.bottomLeft,
                          child: Container(
                            padding: EdgeInsets.symmetric(
                                horizontal: ScreenUtil().setWidth(10)),
                            decoration: BoxDecoration(
                              border: Border.all(
                                color: model
                                    .themeModel.customThemeData.mainTextColor
                                    .withRed(100),
                                width: ScreenUtil().setWidth(1),
                              ),
                              borderRadius: BorderRadius.all(
                                Radius.circular(
                                  ScreenUtil().setWidth(5),
                                ),
                              ),
                            ),
                            child: Text(
                              model.bookInfo.book.bookType,
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                height: ScreenUtil().setHeight(2),
                                fontSize: ScreenUtil().setSp(24),
                                color: model
                                    .themeModel.customThemeData.mainTextColor
                                    .withRed(100),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}

//Expanded(
//flex: 1,
//child: Container(
//alignment: Alignment.bottomLeft,
//child: Text(
//"最新章节:" +
//model.bookInfo
//    .list[model.bookInfo.list.length - 1].name,
//style: TextStyle(
//color: model
//    .themeModel.customThemeData.mainTextColor
//    .withOpacity(0.5),
//fontSize: ScreenUtil()
//    .setSp(26, allowFontScalingSelf: true),
//),
//),
//),
//),
